package com.xiaoshuidi.cloud.module.iot.controller.admin.callback;

import com.xiaoshuidi.cloud.module.iot.dal.model.callback.TianchengCallbackReqVO;
import com.xiaoshuidi.cloud.module.iot.dal.model.callback.TianchengDeviceCallbackResVO;
import com.xiaoshuidi.cloud.module.iot.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.iot.service.TianchengCallbackService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(ApiConstants.NAME + "/callback")
public class TianchengDeviceController {

    private Logger LOGGER = LoggerFactory.getLogger(TianchengDeviceController.class);

    @Autowired
    private TianchengCallbackService tianchengCallbackService;

    /**
     * 天诚回调请求处理
     *
     * @param tianchengCallbackReqVO
     * @return
     */
    @PostMapping("/tiancheng")
    public TianchengDeviceCallbackResVO callback(@RequestBody TianchengCallbackReqVO tianchengCallbackReqVO) throws Exception {
        LOGGER.info("天诚回调请求，请求内容:{}", tianchengCallbackReqVO.toString());
        TianchengDeviceCallbackResVO tianchengDeviceCallbackResVO = tianchengCallbackService.disposeCallback(tianchengCallbackReqVO);
        return tianchengDeviceCallbackResVO;
    }
}
